
/**
 * 秒转分钟，无单位
 * @params difftime {String} 秒
 */
const beautifyMinuteTimeNoUnit = function(difftime) {
  if (difftime === undefined || difftime === null) {
    return '-';
  }
  return Number((difftime / 60).toFixed(2)) * 1;
};

/**
 * 秒转分钟
 * @params difftime {String} 秒
 */
const beautifyMinuteTime = function(difftime) {
  if (difftime === undefined || difftime === null) {
    return '-';
  }
  return `${Number((difftime / 60).toFixed(2)) * 1} 分`;
};

const beautifyHourMinuteSecond = function (difftime) {
  if (difftime === undefined || difftime === null) {
    return '-';
  }

  let formatArr = [];
  if (difftime>3600) {
    formatArr.push(Math.floor(difftime/3600) + 'h');
    difftime = difftime%3600;
  }

  if (difftime>60) {
    formatArr.push(Math.floor(difftime/60) + 'm');
    difftime = difftime%60;
  }

  formatArr.push(difftime + 's');
  return formatArr.join('');
}

export default {
  beautifyMinuteTimeNoUnit,
  beautifyMinuteTime,
  beautifyHourMinuteSecond
};
